package com.ruoyi.project.charge.controller;

import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.domain.BaseEntity;
import com.ruoyi.framework.web.page.TableDataInfo;
import com.ruoyi.project.charge.domin.ChargeDetail;
import com.ruoyi.project.charge.domin.ChargeQuery;
import com.ruoyi.project.charge.service.IChargeQueryService;
import com.ruoyi.project.charge.vo.ChargeParams;
import com.ruoyi.project.charge.vo.ChargeQueryParams;
import com.ruoyi.project.charge.vo.RefundParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @auther:YU JIANG
 * @date:2021/7/15
 * @time:10:54
 */
@RestController
@RequestMapping("/system/query")
public class ChargeQueryController extends BaseController {

    @Autowired
    private IChargeQueryService iChargeQueryService;

    @GetMapping("/queryAll")
    public TableDataInfo queryAll(ChargeQueryParams chargeQueryParams){
        startPage();
        List<ChargeQuery> list = iChargeQueryService.queryAll(chargeQueryParams);
        return getDataTable(list);
    }

    @GetMapping("/queryDetail")
    public AjaxResult queryDetail(String order_id){
        System.out.println(order_id);
        List<ChargeDetail> list = iChargeQueryService.queryAll2(order_id);
        return AjaxResult.success(list);
    }

    //修改支付状态
    @GetMapping("/updateStatus2")
    @PreAuthorize("@ss.hasPermi('charge:charge:query')")
    public AjaxResult updateStatus2(RefundParams params){
        System.out.println(params);
        int i = iChargeQueryService.updateChargeQuery(params);
        return toAjax(i);
    }
}
